Bach's algorithm